﻿within ;
model MEC_DC_Motor_1 "直流电机建模练习"
  parameter Modelica.SIunits.Voltage Va = 100 "实际电枢电压 Actual armature voltage";
  parameter Modelica.SIunits.Time tStart = 0.2
    "斜坡电压源启动时刻 Start of armature voltage ramp";
  parameter Modelica.SIunits.Time tRamp = 0.0 "斜坡电压源上升时间 Armature voltage ramp";
  parameter Modelica.SIunits.Voltage Ve = 100 "实际励磁电压 Actual excitation voltage";
  parameter Modelica.SIunits.Torque TLoad = 63.66 "额定负载转矩 Nominal load torque";
  parameter Modelica.SIunits.Time tStep = 1.5 "负载转矩加载时刻 Time of load torque step";
  parameter Modelica.SIunits.Inertia JLoad = 0.15
    "负载转动惯量 Load's moment of inertia";
  Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_ElectricalExcited dcee(
    VaNominal = dceeData.VaNominal, 
    IaNominal = dceeData.IaNominal, 
    wNominal = dceeData.wNominal, 
    TaNominal = dceeData.TaNominal, 
    Ra = dceeData.Ra, 
    TaRef = dceeData.TaRef, 
    La = dceeData.La, 
    Jr = dceeData.Jr, 
    useSupport = false, 
    Js = dceeData.Js, 
    frictionParameters = dceeData.frictionParameters, 
    coreParameters = dceeData.coreParameters, 
    strayLoadParameters = dceeData.strayLoadParameters, 
    brushParameters = dceeData.brushParameters, 
    IeNominal = dceeData.IeNominal, 
    Re = dceeData.Re, 
    TeRef = dceeData.TeRef, 
    Le = dceeData.Le, 
    sigmae = dceeData.sigmae, 
    TaOperational = 293.15, 
    alpha20a = dceeData.alpha20a, 
    phiMechanical(fixed = true), 
    wMechanical(fixed = true), 
    ia(fixed = true), 
    alpha20e = dceeData.alpha20e, 
    TeOperational = 293.15, 
    ie(fixed = true)) annotation (Placement(transformation(extent = {{-20, -50}, 
      {0, -30}})));
  Modelica.Blocks.Sources.Ramp ramp(
    duration = tRamp, 
    height = Va, 
    startTime = tStart) annotation (Placement(transformation(extent = {{-80, 
      60}, {-60, 80}})));
  Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage
    annotation (Placement(transformation(extent = {{0, 30}, {-20, 50}})));
  Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(
    transformation(
      origin = {-70, 40}, 
      extent = {{-10, -10}, {10, 10}}, 
      rotation = 270)));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V = Ve)
    annotation (Placement(transformation(
      origin = {-40, -40}, 
      extent = {{-10, -10}, {10, 10}}, 
      rotation = 270)));
  Modelica.Electrical.Analog.Basic.Ground groundExcitation annotation (
    Placement(transformation(
      origin = {-70, -50}, 
      extent = {{-10, -10}, {10, 10}}, 
      rotation = 270)));
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J = JLoad)
    annotation (Placement(transformation(extent = {{40, -50}, {60, -30}})));
  Modelica.Mechanics.Rotational.Sources.TorqueStep loadTorqueStep(
    startTime = tStep, 
    stepTorque = -TLoad, 
    useSupport = false, 
    offsetTorque = 0) annotation (Placement(transformation(extent = {{90, -50}, 
      {70, -30}})));
  parameter Modelica.Electrical.Machines.Utilities.ParameterRecords.DcElectricalExcitedData dceeData
    annotation (Placement(transformation(extent = {{-20, -80}, {0, -60}})));
  annotation (Diagram(coordinateSystem(extent = {{-100.0, -100.0}, {100.0, 100.0}}, 
    grid = {2.0, 2.0}), graphics = {Text(origin = {33.0, 40.0}, 
    extent = {{-27.0, 10.0}, {27.0, -10.0}}, 
    textString = "可调电枢电源", 
    fontSize = 12, 
    textStyle = {TextStyle.None}), Text(origin = {-20.0, 84.0}, 
    extent = {{-18.0, 10.0}, {18.0, -10.0}}, 
    textString = "可调整斜坡信号发生器
的幅值和上升时间", 
    fontSize = 12, 
    textStyle = {TextStyle.None}), Text(origin = {-72.0, -20.0}, 
    extent = {{-18.0, 10.0}, {18.0, -10.0}}, 
    textString = "提供额定
励磁电压", 
    fontSize = 12, 
    textStyle = {TextStyle.None}), Text(origin = {36.0, -22.0}, 
    extent = {{-18.0, 10.0}, {18.0, -10.0}}, 
    textString = "惯量负载", 
    fontSize = 12, 
    textStyle = {TextStyle.None}), Text(origin = {78.0, -68.0}, 
    extent = {{-18.0, 10.0}, {18.0, -10.0}}, 
    textString = "突加
负载转矩", 
    fontSize = 12, 
    textStyle = {TextStyle.None})}));
equation 
  connect(ramp.y, signalVoltage.v)
    annotation (Line(origin = {-34.5, 61.0}, 
      points = {{-25.0, 9.0}, {25.0, 9.0}, {25.0, -9.0}}, 
      color = {0, 0, 255}));
  connect(signalVoltage.p, dcee.pin_ap)
    annotation (Line(origin = {-2.0, 5.0}, 
      points = {{2.0, 35.0}, {2.0, -25.0}, {-2.0, -25.0}, {-2.0, -35.0}}, 
      color = {0, 0, 255}));
  connect(signalVoltage.n, ground.p)
    annotation (Line(origin = {-40.0, 40.0}, 
      points = {{20.0, 0.0}, {-20.0, 0.0}}, 
      color = {0, 0, 255}));
  connect(dcee.pin_an, ground.p)
    annotation (Line(origin = {-38.0, 5.0}, 
      points = {{22.0, -35.0}, {22.0, -25.0}, {18.0, -25.0}, {18.0, 35.0}, {-22.0, 35.0}}, 
      color = {0, 0, 255}));
  connect(constantVoltage.n, groundExcitation.p)
    annotation (Line(origin = {-50.0, -50.0}, 
      points = {{10.0, 0.0}, {-10.0, 0.0}}, 
      color = {0, 0, 255}));
  connect(dcee.pin_ep, constantVoltage.p)
    annotation (Line(origin = {-30.0, -32.0}, 
      points = {{10.0, -2.0}, {0.0, -2.0}, {0.0, 2.0}, {-10.0, 2.0}}, 
      color = {0, 0, 255}));
  connect(dcee.pin_en, constantVoltage.n)
    annotation (Line(origin = {-30.0, -48.0}, 
      points = {{10.0, 2.0}, {0.0, 2.0}, {0.0, -2.0}, {-10.0, -2.0}}, 
      color = {0, 0, 255}));
  connect(loadInertia.flange_b, loadTorqueStep.flange)
    annotation (Line(origin = {65.0, -40.0}, 
      points = {{-5.0, 0.0}, {5.0, 0.0}}));
  connect(dcee.flange, loadInertia.flange_a)
    annotation (Line(origin = {20.0, -40.0}, 
      points = {{-20.0, 0.0}, {20.0, 0.0}}));
end MEC_DC_Motor_1;